﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LINQ
{
    public class Student
    {
        public String Name { get; set; }
        public String LastName { get; set; }
        public int Age { get; set; }

        public override string ToString()
        {
            return this.Name + " " + this.LastName +" " + this.Age;
        }
    }
    
    class LINQ_Exercises
    {
        static Student[] students = new Student[]
        {
                 new Student{ Name = "Valio", LastName = "Peev", Age = 17},
                 new Student{ Name = "ANGEL", LastName = "Zarev", Age = 20},
                 new Student{ Name = "Pesho", LastName = "Mladenov", Age = 24},
                 new Student{ Name = "Ivan", LastName = "Baev", Age = 22},
                 new Student{ Name = "Ivan", LastName = "Stoev", Age = 29}
                
        };

        static void Main(string[] args)
        {
            var queryStudents =
                from student in students
                where student.Name.CompareTo( student.LastName) < 0
                select student;

            var queryStudents2 =
                from student in students
                where student.Age >18 && student.Age <24
                select student;

            foreach (var item in queryStudents2)
        	{
        		 Console.WriteLine(item);
        	}

        }
    }
}
